﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Konekcija.Core.Reporting.Dto.Application.Files;

namespace Konekcija.Core.Reporting.Mappings.Files
{
    public class VideoMap : ClassMap<Video>
    {
        public VideoMap()
        {
            Schema("files");
            Table("Videos");

            Id(x => x.Id).GeneratedBy.GuidComb().Not.Nullable();
            Map(x => x.ItemId).Column("ItemId")
                .Not.Insert().Not.Update().Nullable();
            Map(x => x.UrlFull).Nullable();
            Map(x => x.UrlMedium).Nullable();
            Map(x => x.UrlSmall).Nullable();
            Map(x => x.Importance).Nullable();
            Map(x => x.Type).Nullable();
            Map(x => x.Size).Nullable();
            Map(x => x.Source).Nullable();
            Map(x => x.DateCreated).Nullable();
            Map(x => x.DateChanged).Nullable();
            Map(x => x.ByUserId).Nullable();


            HasMany(x => x.VideoLanguages)
                .Inverse()
                .AsBag()
                .Key(k => k.Not.Nullable())
                .KeyColumn("VideoId")
                .Fetch.Join();

            References(x => x.Item).Nullable();
        }
    }
}
